<?php

/**
 * 多继承 trait
 */

trait Log
{

    public function save()
    {
        return __METHOD__;
    }

    public static function test()
    {
        return __METHOD__;
    }

    public abstract function abstractMethod();
}

trait Comment
{
    public function total()
    {
        return __METHOD__;
    }

    public function save()
    {
        return __METHOD__;
    }
}

class Topic
{
    // 解决继承多 trait 方法重名问题
    use Log, Comment {
        Log::save insteadof Comment; // 替换方法
        Comment::save as send; // 别名
    }

    public function save()
    {
        $this->save();
        return 'topic save';
    }

    public function abstractMethod()
    {

    }

}


$topic = new Topic();
echo $topic->save();
echo $topic->total();
